package com.sdry.service.impl.zc;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.sdry.mapper.zc.ZcInspectionSheetMapper;
import com.sdry.model.zc.ZcInspectionSheetEntity;
import com.sdry.model.zc.ZcProductTestEntity;
import com.sdry.model.zc.ZcProductTestValueEntity;
import com.sdry.model.zc.ZcQueryCriteria;
import com.sdry.service.zc.ZcInspectionSheetService;

/**
 * 
 * @ClassName:    ZcInspectionSheetServiceImpl   
 * @Description:  产品检测
 * @Author:       zc   
 * @CreateDate:   2019年1月4日 上午10:58:32   
 * @Version:      v1.0
 */
@Service
public class ZcInspectionSheetServiceImpl implements ZcInspectionSheetService {

	@Resource
	private ZcInspectionSheetMapper zcInspectionSheetMapper;
	/**
	 * 查询产品检验的列表
	 */
	@Override
	public List<ZcInspectionSheetEntity> selectInspectionSheetList(ZcQueryCriteria zcQueryCriteria) {
		return zcInspectionSheetMapper.selectInspectionSheetList(zcQueryCriteria);
	}
	/**
	 * 查询产品检验单列表数目
	 */
	@Override
	public int countInspectionSheetList(ZcQueryCriteria zcQueryCriteria) {
		return zcInspectionSheetMapper.countInspectionSheetList(zcQueryCriteria);
	}
	/**
	 * 通过排产单查询该排产单下所有的检验结果
	 * @param remark02
	 * @return
	 */
	@Override
	public List<ZcProductTestEntity> selectRemark03Byremark02(String remark02) {
		return zcInspectionSheetMapper.selectRemark03Byremark02(remark02);
	}
	/**
	 * 通过排产单号和检测结果类型查询产品检验数据
	 * @param zcQueryCriteria
	 * @return
	 */
	@Override
	public ZcProductTestValueEntity selectProductTestValue(ZcQueryCriteria zcQueryCriteria) {
		return zcInspectionSheetMapper.selectProductTestValue(zcQueryCriteria);
	}
	/**
	 * 保存产品检验单信息
	 */
	@Override
	public int insertInspectionSheet(ZcInspectionSheetEntity zcInspectionSheetEntity) {
		return zcInspectionSheetMapper.insertInspectionSheet(zcInspectionSheetEntity);
	}
	/**
	 * 保存产品检验单详情
	 */
	@Override
	public int insertInspectionSheetDetails(ZcInspectionSheetEntity zcInspectionSheetEntity) {
		String isItem = zcInspectionSheetEntity.getIsItem();
		String isItemArr[] = isItem.split(",", -1);
		String isValue = zcInspectionSheetEntity.getIsValue();
		String isValueArr[] = isValue.split(",", -1);
		String isCheckNum = zcInspectionSheetEntity.getIsCheckNum();
		String isCheckNumArr[] = isCheckNum.split(",", -1);
		String isBetterNum = zcInspectionSheetEntity.getIsBetterNum();
		String isBetterNumArr[] = isBetterNum.split(",", -1);
		String isDecide = zcInspectionSheetEntity.getIsDecide();
		String isDecideArr[] = isDecide.split(",", -1);
		int length = isItemArr.length;
		int affact = 0;
		for(int i = 0;i<length;i++){
			zcInspectionSheetEntity.setIsItem(isItemArr[i]);
			zcInspectionSheetEntity.setIsValue(isValueArr[i]);
			zcInspectionSheetEntity.setIsCheckNum(isCheckNumArr[i]);
			zcInspectionSheetEntity.setIsBetterNum(isBetterNumArr[i]);
			zcInspectionSheetEntity.setIsDecide(isDecideArr[i]);
			affact += zcInspectionSheetMapper.insertInspectionSheetDetails(zcInspectionSheetEntity);
		}
		return affact;
	}
	/**
	 * 查询产品检验单详情
	 */
	@Override
	public List<ZcInspectionSheetEntity> selectInspectionSheetDetailsListByNumber(ZcQueryCriteria zcQueryCriteria) {
		return zcInspectionSheetMapper.selectInspectionSheetDetailsListByNumber(zcQueryCriteria);
	}
	/**
	 * 查询产品检验单详情数目
	 */
	@Override
	public int countInspectionSheetDetailsListByNumber(ZcQueryCriteria zcQueryCriteria) {
		return zcInspectionSheetMapper.countInspectionSheetDetailsListByNumber(zcQueryCriteria);
	}
	/**
	 * 批量删除
	 */
	@Override
	public int delInspectionSheetArr(String isNumber) {
		return zcInspectionSheetMapper.delInspectionSheetArr(isNumber);
	}

}
